﻿'========================================================================
'功能:群組物件商業邏輯物件
'作者:andy
'日期: 2011/1/31
'========================================================================

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Data.SqlClient
Imports System.Text
Imports System.Data
Namespace OAMS.BBL
    Public Class GroupBBL

        ''' <summary>
        ''' 取得所有群組資料
        ''' </summary>
        ''' <returns>取得所有群組資料</returns>
        ''' <remarks>取得所有群組資料</remarks>
        Public Function GetGroupIDdt(ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            Return db1.GetGroupIDdt()

        End Function


        ''' <summary>
        ''' 取得所有群組資料及一筆可以新增的紀錄
        ''' </summary>
        ''' <returns>取得所有群組資料及一筆可以新增的紀錄</returns>
        ''' <remarks>取得所有群組資料及一筆可以新增的紀錄</remarks>
        Public Function GetGroupIDInsert(ByVal dbName As String) As DataTable

            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            Return db1.GetGroupIDInsert()
        End Function

        ''' <summary>
        ''' 取得群組權限的資料
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <param name="ProgramID"></param>
        ''' <returns>取得群組權限的資料</returns>
        ''' <remarks>取得群組權限的資料</remarks>
        Public Function GetGroupRights(ByVal GroupID As String, ByVal ProgramID As Integer, ByVal dbName As String) As DataTable

            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            Return db1.GetGroupRights(GroupID, ProgramID)
        End Function
        ''' <summary>
        ''' 修改群組權限的資料
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <param name="ProgramID"></param>
        ''' <param name="SeqNo"></param>
        ''' <param name="UseRight"></param>
        ''' <param name="UID"></param>
        ''' <remarks>修改群組權限的資料</remarks>
        Public Sub UpdateRight(ByVal GroupID As String, ByVal ProgramID As Integer, ByVal SeqNo As Integer, ByVal UseRight As Boolean, ByVal UID As String, ByVal dbName As String)

            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            db1.UpdateRight(GroupID, ProgramID, SeqNo, UseRight, UID)

        End Sub

        ''' <summary>
        ''' 修改或新增一筆資料到群組資料表中
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <param name="GroupName"></param>
        ''' <param name="UID"></param>
        ''' <param name="canModi">true代表是新增</param>
        ''' <remarks>修改或新增一筆資料到群組資料表中</remarks>
        Public Sub UpdateGroupID(ByVal GroupID As String, ByVal GroupName As String, ByVal UID As String, ByVal canModi As Boolean, ByVal dbName As String, ByVal RootID As String)

            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            db1.UpdateGroupID(GroupID, GroupName, UID, canModi, RootID)

        End Sub



        ''' <summary>
        ''' 檢查某一個群組代號是否存在
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <returns>檢查某一個群組代號是否存在</returns>
        ''' <remarks>檢查某一個群組代號是否存在</remarks>
        Public Function GroupIDIsExist(ByVal GroupID As String, ByVal dbName As String) As Boolean
            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            Return db1.GroupIDIsExist(GroupID)
        End Function

        ''' <summary>
        ''' 檢查人員是否屬於某一群組
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <param name="UID"></param>
        ''' <returns>檢查人員是否屬於某一群組</returns>
        ''' <remarks>檢查人員是否屬於某一群組</remarks>
        Public Function GroupMemberIsExist(ByVal GroupID As String, ByVal UID As String, ByVal dbName As String) As Boolean
            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)

            Return db1.GroupMemberIsExist(GroupID, UID)
        End Function

        ''' <summary>
        ''' 新增群組人員資料
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <param name="UID1"></param>
        ''' <param name="CrtUID"></param>
        ''' <remarks>新增群組人員資料</remarks>
        Public Sub InsertGroupMember(ByVal GroupID As String, ByVal UID1 As String, ByVal CrtUID As String, ByVal dbName As String)

            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            db1.InsertGroupMember(GroupID, UID1, CrtUID)
        End Sub

        ''' <summary>
        ''' 刪除群組人員資料
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <param name="UID1"></param>
        ''' <remarks>刪除群組人員資料</remarks>
        Public Sub DeleteGroupMember(ByVal GroupID As String, ByVal UID1 As String, ByVal dbName As String)
            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            db1.DeleteGroupMember(GroupID, UID1)
        End Sub

        ''' <summary>
        ''' 取得個人的所有群組資料
        ''' </summary>
        ''' <param name="UID"></param>
        ''' <returns>取得個人的所有群組資料</returns>
        ''' <remarks>取得個人的所有群組資料</remarks>
        Public Function GetGroupIDByUID(ByVal UID As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            Return db1.GetGroupIDByUID(UID)
        End Function

        Public Function GetGroupIDByUID(ByVal UID As String, ByVal Kind As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            Return db1.GetGroupIDByUID(UID, Kind)
        End Function

        ''' <summary>
        ''' 取得群組的所有人員資料
        ''' </summary>
        ''' <param name="GroupID"></param>
        ''' <returns>取得群組的所有人員資料</returns>
        ''' <remarks>取得群組的所有人員資料</remarks>
        Public Function GetUIDByGroupID(ByVal GroupID As String, ByVal dbName As String) As DataTable

            Dim db1 As OAMS.DAO.GroupDAO = New OAMS.DAO.GroupDAO(dbName)
            Return db1.GetUIDByGroupID(GroupID)
        End Function
    End Class

End Namespace

